﻿@{
    ViewBag.Title = "修改";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@model YTCMS.Domain.Entities.vehicle
@using YTCMS.Core
<div class="row">
    <div class="col-lg-12">
        <h3 class="page-header"><i class="fa fa-laptop"></i> 宇途后台管理系统</h3>
        <ol class="breadcrumb">
            <li><i class="fa fa-home"></i><a href="/">主页</a></li>
            <li><i class="fa fa-laptop"></i><a href="/vehicle/index">交通工具管理</a></li>
            <li><i class="fa fa-plus"></i>修改</li>
        </ol>
    </div>
</div>

<div class="row">
    <div class="col-xs-12">
        <div class="panel panel-default">
            <div class="panel-heading">
                <h2><i class="fa fa-indent red"></i><strong>交通工具管理</strong></h2>
            </div>
            <div class="panel-body">
                <form action="" method="post" id="form1" name="form1" enctype="multipart/form-data" class="form-horizontal col-xs-10">
                    @Html.ValidationSummary(true)
                    <div class="form-group">
                        <label class="col-md-3 control-label" for="text-input">交通工具名称</label>
                        <div class="col-md-9">
                            @Html.TextBoxFor(s => s.Name, new { @class = "form-control", @placeholder = "交通工具名称" })
                            @Html.ValidationMessageFor(s => s.Name)
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-md-3 control-label" for="text-input">买入价</label>
                        <div class="col-md-9">
                            @Html.TextBoxFor(s => s.Pay, new { @class = "form-control", @placeholder = "买入价" })
                            @Html.ValidationMessageFor(s => s.Pay)
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-md-3 control-label" for="text-input">销售价</label>
                        <div class="col-md-9">
                            @Html.TextBoxFor(s => s.Market, new { @class = "form-control", @placeholder = "销售价" })
                            @Html.ValidationMessageFor(s => s.Market)
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-md-3 control-label" for="text-input">状态</label>
                        <div class="col-md-9">
                            @Html.DropDownListFor(s => s.State, Admin.Common.YTDDL.CommonState(true, Model.State.ToString()), new { @class = "form-control" })
                            @Html.ValidationMessageFor(s => s.State)
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-md-3 control-label" for="text-input">备注</label>
                        <div class="col-md-9">
                            @Html.TextAreaFor(s => s.Remark, new { @class = "form-control" })
                        </div>
                    </div>
                    <br>
                    @Html.HiddenFor(s => s.Id)
                    @Html.HiddenFor(s=>s.CreateTime)
                </form>
            </div>
            <div class="panel-footer">
                <button type="submit" class="btn btn-sm btn-success" id="btn_Save1"><i class="fa fa-dot-circle-o"></i> 保存</button>
                <button type="reset" class="btn btn-sm btn-danger" onclick="javascript:document.form1.reset();"><i class="fa fa-ban"></i> 重置</button>
            </div>
        </div>
    </div>
</div>

<script>
    $(function () {
        var editor;
        KindEditor.ready(function (K) {
            editor = K.create('textarea[name="Remark"]', {
                uploadJson: '/Util/KindEditorHandlerFile',
                afterBlur: function () { editor.sync(); },
                allowFileManager: true
            });
        });

        $("#btn_Save1").click(function () {
            if ($("#form1").valid()) {
                $.post("/Vehicle/Edit", $("#form1").serialize(), function (result) {
                    if (result.d) {
                        jAlert("修改成功", "提示", function () { window.location.href = "/Vehicle/index" });
                    }
                    else {
                        jAlert(result.msg, "提示");
                    }
                })
            }
        });
    })
</script>